package com.freshcity.page.tree
{
	import com.freshcity.ILayer;
	import com.freshcity.component.container.Component;
	import com.freshcity.core.BaseHomeWin;
	import com.freshcity.core.MainScene;
	import com.freshcity.tree.HomeWin;
	
	import fl.events.ListEvent;
	
	import flash.display.DisplayObjectContainer;
	import flash.events.Event;
	import flash.events.MouseEvent;

	public class TreeHome extends BaseHomeWin
	{
		private var back:HomeWin;

		public function TreeHome(mainScene:MainScene,parent:ILayer=null, xpos:Number=0, ypos:Number=0)
		{
			this.main = mainScene;
			super(parent, xpos, ypos,"梧桐树");
			back.tabMenu.addEventListener(ListEvent.ITEM_CLICK, drawContent);
		}

		override protected function initContent(index:int):void
		{
			var c:Component;
			switch (index)
			{
				case 0:
				{
					if (main.user.sex == 'female')
					{
						c=new MyTree();
					}
					else
					{
						c=new InWater();
					}
					break;
				}
				case 1:
				{
					if (main.user.sex == 'female')
					{
						c=new InWater();
					}
					else
					{
						c=new TreeWorld();
					}
					break;
				}
				case 2:
				{
					if (main.user.sex == 'female')
						c=new TreeWorld();
					break;
				}
			}
			c.main=this.main;
			_contains[index]=c;
		}

		override protected function addChildren():void
		{
			super.addChildren();
			back=new HomeWin();
			addChild(back);
			
			//根据性别设置菜单
			if (main.user.sex == 'female')
			{
				back.tabMenu.arrBtnLabels=["我的梧桐树", "每日采水", "树的世界"];
			}
			else
			{
				back.tabMenu.arrBtnLabels=["每日采水", "树的世界"];
			}				
			
			container=back.container;
			container.mouseEnabled=false;
			container.tabEnabled=false;
		}

		override public function destroy():void
		{
			super.destroy();
		}

		override public function show(event:Event=null):void
		{
			super.show(event);
			back.tabMenu.selectedIndex = 0;
			back.tabMenu.dispatchEvent(new ListEvent(ListEvent.ITEM_CLICK, false, true, 0, 0, 0));
		}
	}
}
